home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ABUSESRC.ZIP / AbuseSrc / macabuse / src / mono_cfg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-20  |  4.8 KB  |  180 lines

  1. #include "input.hpp"
  2. #include "key_cfg.hpp"
  3. #include "game.hpp"
  4. #include "dev.hpp"
  5. #include "gui.hpp"
  6.  
  7. #ifdef __MAC__
  8. extern int PixMode;
  9. #endif
  10.  
  11. extern int start_edit,start_running;
  12.  
  13. enum monitor_draw_type { 
  14.   MONITOR_DOUBLE_PIXEL=1,
  15.   MONITOR_SCANLINED=2,
  16.   MONITOR_SINGLE_PIXEL=3,
  17.   MONITOR_SMOOTH_PIXEL=4,
  18.   MONITOR_ROUND_PIXEL=5
  19.  
  20. } monitor_draw_mode=MONITOR_DOUBLE_PIXEL;
  21.  
  22. enum { EDIT_SWITCH=10,
  23.        OK,
  24.        CANCEL
  25. };
  26.         
  27.  
  28. static ifield *center_ifield(ifield *i, ifield *above, window_manager *eh)
  29. {
  30.   int x1,y1,x2,y2;
  31.  
  32.   if (above)
  33.   {
  34.     above->area(x1,y1,x2,y2,eh);
  35.     i->y=y2+5;
  36.   }
  37.  
  38.   i->area(x1,y1,x2,y2,eh);
  39.   i->x=xres/2-(x2-x1)/2;
  40.   return i;
  41. }
  42.  
  43.  
  44. void do_monitor_config(window_manager *eh)
  45. {
  46.   int xp,yp;
  47.   load_image_into_screen("art/mon_cfg.spe","monitor_config",xp,yp);
  48.   ifield *first,**p;
  49.   p=&first;
  50.  
  51.   ifield *first_button,**b,*prev;
  52.   b=&first_button;
  53.  
  54.   int mode1=cash.reg("art/mon_cfg.spe","mode1",SPEC_IMAGE,1),
  55.     mode1a=cash.reg("art/mon_cfg.spe","mode1+",SPEC_IMAGE,1),
  56.     mode2=cash.reg("art/mon_cfg.spe","mode2",SPEC_IMAGE,1),
  57.     mode2a=cash.reg("art/mon_cfg.spe","mode2+",SPEC_IMAGE,1),
  58.     mode3=cash.reg("art/mon_cfg.spe","mode3",SPEC_IMAGE,1),
  59.     mode3a=cash.reg("art/mon_cfg.spe","mode3+",SPEC_IMAGE,1),
  60.     mode4=cash.reg("art/mon_cfg.spe","mode4",SPEC_IMAGE,1),
  61.     mode4a=cash.reg("art/mon_cfg.spe","mode4+",SPEC_IMAGE,1),
  62.     mode5=cash.reg("art/mon_cfg.spe","mode5",SPEC_IMAGE,1),
  63.     mode5a=cash.reg("art/mon_cfg.spe","mode5+",SPEC_IMAGE,1)
  64.     ;
  65.  
  66.  
  67.   int x=xres/2-90/2,y=yp+160;
  68.   ico_button *b1=new ico_button(x,y,MONITOR_DOUBLE_PIXEL,mode1,mode1,mode1a,mode1a,0,-1,"double_pix");
  69.   ico_button *b2=new ico_button(x,y,MONITOR_SCANLINED,mode2,mode2,mode2a,mode2a,0,-1,"scanlined_pix");
  70.   ico_button *b3=new ico_button(x,y,MONITOR_SINGLE_PIXEL,mode3,mode3,mode3a,mode3a,0,-1,"single_pix");
  71.   ico_button *b4=new ico_button(x,y,MONITOR_ROUND_PIXEL,mode4,mode4,mode4a,mode4a,0,-1,"round_pix");
  72.   ico_button *b5=new ico_button(x,y,MONITOR_SMOOTH_PIXEL,mode5,mode5,mode5a,mode5a,0,-1,"smooth_pix");
  73.   b1->next=b2;
  74.   b2->next=b3;
  75.   b3->next=b4;
  76.   b4->next=b5;
  77.  
  78.   prev=*p=new ico_switch_button(x,y,ID_NULL,
  79.       monitor_draw_mode-1,b1,0);
  80.  
  81.   p=&((*p)->next);
  82.  
  83.   prev=*p=(button *)center_ifield(new button(xp+0,yp+0,EDIT_SWITCH,             "   Edit Mode  ",0),prev,eh);
  84.   if (dev&EDIT_MODE)
  85.     ((button *)(*p))->push();
  86.  
  87.   (*p)->y+=34;
  88.   p=&((*p)->next);
  89.  
  90.   image *ok_image=cash.img(cash.reg("art/frame.spe","dev_ok",SPEC_IMAGE,1))->copy(),
  91.     *cancel_image=cash.img(cash.reg("art/frame.spe","cancel",SPEC_IMAGE,1))->copy();
  92.  
  93.   *p=new button(xp+315-20-8,yres/2+480/2-80,OK,ok_image,0); p=&((*p)->next);
  94.   *p=new button(xp+315+20-8,yres/2+480/2-80,CANCEL,cancel_image,0); p=&((*p)->next);
  95.   
  96.   input_manager inm(screen,eh,first);
  97.   inm.allow_no_selections();
  98.   inm.clear_current();
  99.   event ev;
  100.  
  101.   enum { looping, aborted, finished } state=looping;
  102.  
  103.   int new_dev=dev;
  104.   monitor_draw_type new_monitor_draw_mode=monitor_draw_mode;
  105.   do
  106.   {
  107.     eh->flush_screen();
  108.     do { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting()); 
  109.     inm.handle_event(ev,NULL,eh);
  110.     if (ev.type==EV_KEY && ev.key==JK_ESC)
  111.       state=aborted;
  112.     
  113.     if (ev.type==EV_MESSAGE)
  114.     {
  115.       switch (ev.message.id)
  116.       {
  117.         case OK :
  118.         { state=finished; } break;
  119.         case CANCEL :
  120.         { state=aborted; } break;
  121.         case EDIT_SWITCH :
  122.         { 
  123.           new_dev ^= EDIT_MODE;
  124.         } break;
  125.  
  126.         case MONITOR_SINGLE_PIXEL :
  127.         { new_monitor_draw_mode=MONITOR_SINGLE_PIXEL; } break;
  128.  
  129.         case MONITOR_SCANLINED :
  130.         { new_monitor_draw_mode=MONITOR_SCANLINED; } break;
  131.  
  132.         case MONITOR_DOUBLE_PIXEL :
  133.         { new_monitor_draw_mode=MONITOR_DOUBLE_PIXEL; } break;        
  134.  
  135.         case MONITOR_ROUND_PIXEL :
  136.         { new_monitor_draw_mode=MONITOR_ROUND_PIXEL; } break;        
  137.  
  138.         case MONITOR_SMOOTH_PIXEL :
  139.         { new_monitor_draw_mode=MONITOR_SMOOTH_PIXEL; } break;        
  140.       }
  141.     }
  142.  
  143.   } while (state==looping);
  144.  
  145.   if (state==finished)
  146.   {
  147.     dev = new_dev;
  148.     monitor_draw_mode=new_monitor_draw_mode;
  149.  
  150. #ifdef __MAC__
  151.     switch (new_monitor_draw_mode)
  152.     {
  153.       case MONITOR_SINGLE_PIXEL: PixMode=1; break;
  154.       case MONITOR_SCANLINED:    PixMode=2; break;
  155.       case MONITOR_DOUBLE_PIXEL: PixMode=3; break;
  156.       case MONITOR_ROUND_PIXEL:  PixMode=4; break;
  157.       case MONITOR_SMOOTH_PIXEL: PixMode=5; break;
  158.     }
  159. #endif
  160.  
  161.  
  162.     if (dev & EDIT_MODE)
  163.     {
  164.       start_edit = 1;
  165.       start_running = 1;
  166.       disable_autolight = 1;
  167.     }
  168.     else
  169.     {
  170.       start_edit = 0;
  171.       start_running = 0;
  172.       disable_autolight = 0;
  173.     }
  174.     monitor_draw_mode=new_monitor_draw_mode;
  175.   }
  176.   delete ok_image;
  177.   delete cancel_image;
  178.  
  179. }
  180.